//
//  GGTBusinessTableViewCell.m
//  GGT
//
//  Created by 空空空 on 14/11/5.
//  Copyright (c) 2014年 GGT. All rights reserved.
//

#import "GGTBusinessTableViewCell.h"

@implementation GGTBusinessTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.nameLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.nameLabel];
        self.addressLabel= [[UILabel alloc]init];
        [self.contentView addSubview:self.addressLabel];
        self.imgView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgView];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imgView.image = [UIImage imageNamed:@"phone.png"];
    self.nameLabel.text = self.singleBusiness.name;
    self.addressLabel.text = self.singleBusiness.address;
    self.nameLabel.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height / 2);
    self.addressLabel.frame = CGRectMake(10, self.contentView.frame.size.height / 2, self.contentView.frame.size.width / 2 + 80, self.contentView.frame.size.height / 2);
    self.imgView.frame = CGRectMake(self.contentView.frame.size.width / 5 * 4 + 15, self.contentView.frame.size.height / 2 - 10, self.contentView.frame.size.width / 10, self.contentView.frame.size.height / 3);
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(self.contentView.frame.size.width / 5 * 4 + 15, self.contentView.frame.size.height / 2 - 10, self.contentView.frame.size.width / 10, self.contentView.frame.size.height / 3);
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:button];
}
- (void)awakeFromNib {
    // Initialization code
}
//注册消息中心 点击按钮 发送消息给通知中心
- (void)buttonClick:(UIButton *)button
{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center postNotificationName:@"pho" object:self.singleBusiness.telephone userInfo:nil];
    
    
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)dealloc
{
    [_imgView release];
    [_nameLabel release];
    [_addressLabel release];
    [super dealloc];
}
@end
